<div class="clients view">
    <h2 class="left"><?php __('Cliente'); ?></h2>
    <div class="actions specific">
        <ul>
            <li><?php echo $this->Html->link(__('Agregar Auto', true), array('action' => 'agregar_auto', $client['Client']['id'])); ?> </li>
            <li><?php echo $this->Html->link(__('Editar Cliente', true), array('action' => 'edit', $client['Client']['id'])); ?> </li>
            <li><?php echo $this->Html->link(__('Eliminar Cliente', true), array('action' => 'delete', $client['Client']['id']), null, sprintf(__('Esta seguro que desea eliminar el cliente # %s?', true), $client['Client']['last_name'] . ' ' . $client['Client']['first_name'])); ?> </li>
        </ul>
    </div>
    <br />
    <br />
    <br />
    <dl><?php $i = 0;
$class = ' class="altrow"'; ?>
        <dt<?php if ($i % 2 == 0)
            echo $class; ?>><?php __('Id'); ?></dt>
        <dd<?php if ($i++ % 2 == 0)
                echo $class; ?>>
                <?php echo $client['Client']['id']; ?>
            &nbsp;
        </dd>
        <dt<?php if ($i % 2 == 0)
                    echo $class; ?>><?php __('Apellido'); ?></dt>
        <dd<?php if ($i++ % 2 == 0)
                echo $class; ?>>
                <?php echo $client['Client']['last_name']; ?>
            &nbsp;
        </dd>
        <dt<?php if ($i % 2 == 0)
                    echo $class; ?>><?php __('Nombre'); ?></dt>
        <dd<?php if ($i++ % 2 == 0)
                echo $class; ?>>
                <?php echo $client['Client']['first_name']; ?>
            &nbsp;
        </dd>
        <dt<?php if ($i % 2 == 0)
                    echo $class; ?>><?php __('Domicilio'); ?></dt>
        <dd<?php if ($i++ % 2 == 0)
                echo $class; ?>>
                <?php echo $client['Client']['addres']; ?>
            &nbsp;
        </dd>
        <dt<?php if ($i % 2 == 0)
                    echo $class; ?>><?php __('Teléfono'); ?></dt>
        <dd<?php if ($i++ % 2 == 0)
                echo $class; ?>>
                <?php echo $client['Client']['phone']; ?>
            &nbsp;
        </dd>
        <dt<?php if ($i % 2 == 0)
                    echo $class; ?>><?php __('Fecha de Alta'); ?></dt>
        <dd<?php if ($i++ % 2 == 0)
                echo $class; ?>>
                <?php
                $fecha = date('d/m/Y', strtotime($client['Client']['high_date']));
                echo $fecha;
                ?>
            &nbsp;
        </dd>
        <dt<?php if ($i % 2 == 0)
                    echo $class; ?>><?php __('Localidad'); ?></dt>
        <dd<?php if ($i++ % 2 == 0)
                echo $class; ?>>
                <?php echo $client['Client']['locality']; ?>
            &nbsp;
        </dd>
        <dt<?php if ($i % 2 == 0)
                    echo $class; ?>><?php __('Provincia'); ?></dt>
        <dd<?php if ($i++ % 2 == 0)
                echo $class; ?>>
                <?php echo $client['Province']['name']; ?>
            &nbsp;
        </dd>
    </dl>
</div>
<div class="cars index">
    <h2><?php __('Autos'); ?></h2>
    <table cellpadding="0" cellspacing="0">
        <tr>
<!--            <th><?php echo 'Id'; ?></th>-->
            <th><?php echo 'Letra'; ?></th>
            <th><?php echo 'Numero'; ?></th>
            <th><?php echo 'Marca'; ?></th>
            <th><?php echo 'Modelo'; ?></th>
            <th><?php echo 'N° Chasis'; ?></th>
<!--            <th><?php echo 'client_id'; ?></th>-->
            <th class="actions"><?php __('Opciones'); ?></th>
        </tr>
        <?php
        $i = 0;
        foreach ($client['Car'] as $car):
            $class = null;
            if ($i++ % 2 == 0) {
                $class = ' class="altrow"';
            }
            ?>
            <tr<?php echo $class; ?>>
    <!--                <td><?php echo $car['id']; ?>&nbsp;</td>-->
                <td><?php echo $car['letter']; ?>&nbsp;</td>
                <td><?php echo $car['number']; ?>&nbsp;</td>
                <td><?php echo $car['mark']; ?>&nbsp;</td>
                <td><?php echo $car['model']; ?>&nbsp;</td>
                <td><?php echo $car['chassis_number']; ?>&nbsp;</td>
    <!--                <td>
                <?php echo $this->Html->link($client['Client']['last_name'] . ' ' . $client['Client']['first_name'], array('controller' => 'clients', 'action' => 'view', $car['id'])); ?>
                </td>-->
                <td class="actions">
                    <?php echo $this->Html->link(__('Ver', true), array('controller' => 'cars', 'action' => 'view', $car['id'])); ?>
                    <?php 
                    if(sizeof($cars[$car['id']]['Key']) == 0){
                        echo $this->Html->link(__('Agregar Llave', true), array('controller' => 'cars', 'action' => 'agregar_llave', $car['id']));
                    }else{
                        echo $this->Html->link(__('Agregar Copia', true), array('controller'=>'keys', 'action' => 'agregar_copia', $cars[$car['id']]['Key'][0]['id']));
                    }
                     ?>
                    <?php echo $this->Html->link(__('Editar', true), array('controller' => 'cars', 'action' => 'edit', $car['id'])); ?>
                    <?php echo $this->Html->link(__('eliminar', true), array('controller' => 'cars', 'action' => 'delete', $car['id']), null, sprintf(__('Esta seguro que desea eliminar el auto # %s?', true), $car['letter'] . ' ' . $car['number'])); ?>
                </td>
            </tr>
        <?php endforeach; ?>
    </table>
</div>